import Mock from "mockjs";
const { proList } = Mock.mock({
    'proList|100': [
        {
            'bed|1-4':1,
            'price|800-2000': 800,
            'kind|1': ['珠海','吉隆坡','海南','成都','济州岛'],
            proid: 'pro-' + '@guid',
            "iLike|1-2": true,
            "img|1": ["https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u317.png" ,"https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u315.png", "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u338.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u347.png", "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u361.png" , "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u360.png" , "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u383.png" , "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u382.png"],
            'start|1-5': 1
        }
    ]
    
})
Mock.mock('/api/getProListData', 'post', (config) => {
    // console.log(JSON.parse(config.body));
    const req = JSON.parse(config.body)
    return {
        code: 200,
        message: '获取数据成功',
        data: {
            proList:proList,
        }
    }
})
Mock.mock('/api/kindProListData', 'post', (config) => {
    // console.log(JSON.parse(config.body));
    const req = JSON.parse(config.body)
    console.log(req.typename);
    
    const newList =[]
    const res = {
        code: 200,
        message: '获取数据失败',
        data:newList

    }
    
    console.log(1111);
    for (let i = 0; i < proList.length; i++) {
       if(proList[i].kind ==req.typename){
        newList.push(proList[i])
        res.message = '获取数据成功'
        if( newList.length>=2){
            break
        }
        
        // if(newList)
       }
        
    }
    return res
})
const { nameList } = Mock.mock({
'nameList|40': [
    {
          name: '@cname',
        'like|0-200': 0,
        'location|1': ['万达广场','画法商都','鹿回头风景区','九寨沟','济州岛','金湖公园','双子塔'],
        text:' @ctitle(30, 100)',
        "img|1": ["https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u317.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u281.png" ,"https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u449.png", "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u459.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u450.png", "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u361.png" , "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u360.png" , "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u383.png" , "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u382.png"],

    }
]

})
Mock.mock('/api/getnameListData', 'post', (config) => {
    // console.log(JSON.parse(config.body));
    const req = JSON.parse(config.body)
    return {
        code: 200,
        message: '获取数据成功',
        data: {
            nameList:nameList,
        }
    }
})
Mock.mock('/api/fournameListData', 'post', (config) => {
    const req = JSON.parse(config.body)
    const fournameList =[]
    const res = {
        code: 200,
        message: '获取数据失败',
        data:fournameList

    }
    
    for (let i = 0; i <nameList.length; i++) {
    
        fournameList.push(nameList[i])
        res.message = '获取数据成功'
        if( i>=3){
            break
        }
        
        // if(newList)
        
    }
    return res
})
Mock.mock('/api/twonameListData', 'post', (config) => {
    const req = JSON.parse(config.body)
    const twonameList =[]
    const res = {
        code: 200,
        message: '获取数据失败',
        data:twonameList

    }
    
    for (let i = 0; i <nameList.length; i++) {
    
        twonameList.push(nameList[i])
        res.message = '获取数据成功'
        if( i>=1){
            break
        }
        
        // if(newList)
        
    }
    return res
})
const { storyList } = Mock.mock({
    'storyList|39': [
        {
              name: '@cname',
            'like|0-200': 0,
            'message|0-30': 0,
            proid: 'pro-' + '@guid',
            'location|1': ['上海','青岛','珠海','吉隆坡','海南','成都','济州岛'],
            'type|1':['名宿','景点','美景','美食','房源'],
            text:'@cword(13)',
            "img|1": ["https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u449.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u450.png" ,"https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u515.png", "https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u515.png"],
    
        }
    ]
    
    })
    Mock.mock('/api/getstoryListData', 'post', (config) => {
        const req = JSON.parse(config.body)
        const lastList =[]
        const res = {
            code: 200,
            message: '获取数据失败',
            data:lastList
        }
        
        console.log(1111);
        for (let i = 0; i < storyList.length; i++) {
          
            if( i>=3){
                    lastList.push(storyList[i])
                    res.message = '获取数据成功'
           }
            
        }
        return res
    })
    Mock.mock('/api/fourstoryListData', 'post', (config) => {
        const req = JSON.parse(config.body)
        const fourList =[]
        const res = {
            code: 200,
            message: '获取数据失败',
            data:fourList
    
        }
        
        console.log(1111);
        for (let i = 0; i < storyList.length; i++) {
        
            fourList.push(storyList[i])
            res.message = '获取数据成功'
            if( i>=3){
                break
            }
            
            // if(newList)
            
        }
        return res
    })
    const {locationList}= Mock.mock({
        'locationList|30': [
            {
                "img|1":["https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u360.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E9%A6%96%E9%A1%B5/u361.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u631.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u632.png"],
                'location|1': ['万达广场','画法商都','鹿回头风景区','九寨沟','济州岛','金湖公园','双子塔'],
                proid: 'pro-' + '@guid',
                text:' @ctitle(5, 20)',
                'like|0-200': 0,
                name: '@cname'
            }]
    })
    Mock.mock('/api/locationList','post',(config)=>{
        const req = JSON.parse(config.body)
        return {
            code: 200,
            message: '获取数据成功',
            data: {
                locationList:locationList,
            }
        }
    })
    Mock.mock('/api/locationfourList', 'post', (config) => {
        const req = JSON.parse(config.body)
        const locationfourList =[]
        const res = {
            code: 200,
            message: '获取数据失败',
            data:locationfourList
    
        }
        
        console.log(1111);
        for (let i = 0; i < locationList.length; i++) {
        
            locationfourList.push(locationList[i])
            res.message = '获取数据成功'
            if( i>=3){
                break
            }
            
            // if(newList)
            
        }
        return res
    })
    const {foodList}= Mock.mock({
        'foodList|30': [
            {
                "img|1":["https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u633.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u668.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u669.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u667.png"],
                'location|1': ['北京烤鸭馆','特色蒸饺馆','自选餐店','日料寿司店'],
                proid: 'pro-' + '@guid',
                text:' @ctitle(4, 16)',
                'like|0-200': 0,
                name: '@cname'
            }]
    })
    Mock.mock('/api/allfood','post',(config)=>{
        const req = JSON.parse(config.body)
        return {
            code: 200,
            message: '获取数据成功',
            data: {
                foodList:foodList,
            }
        }
    })
    Mock.mock('/api/foodList', 'post', (config) => {
        const req = JSON.parse(config.body)
        const foodfourList =[]
        const res = {
            code: 200,
            message: '获取数据失败',
            data:foodfourList
    
        }
        
        for (let i = 0; i < foodList.length; i++) {
        
            foodfourList.push(foodList[i])
            res.message = '获取数据成功'
            if( i>=3){
                break
            }
            
            // if(newList)
            
        }
        return res
    })
    const {whereList}= Mock.mock({
        'whereList|30': [
            {
                "img|1":["https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u723.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u724.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u725.png","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E5%8F%91%E7%8E%B0/u726.png"],
                'location|1': ['沙漠','广州塔','四川都江堰','珠海长隆海洋王国'],
                proid: 'pro-' + '@guid',
                text:' @ctitle(4, 16)',
                'like|0-200': 0,
                name: '@cname',
                
            }]
    })
    Mock.mock('/api/allwhere','post',(config)=>{
        const req = JSON.parse(config.body)
        return {
            code: 200,
            message: '获取数据成功',
            data: {
                whereList:whereList,
            }
        }
    })
    Mock.mock('/api/whereList', 'post', (config) => {
        const req = JSON.parse(config.body)
        const wherefourList =[]
        const res = {
            code: 200,
            message: '获取数据失败',
            data:wherefourList
    
        }
        
        for (let i = 0; i < whereList.length; i++) {
        
            wherefourList.push(whereList[i])
            res.message = '获取数据成功'
            if( i>=3){
                break
            }
            
            // if(newList)
            
        }
        return res
    })
    const {messageList}= Mock.mock({
        'messageList|3': [
            {
                "img|1":["https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E8%81%8A%E5%A4%A9/u761.svg","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E8%81%8A%E5%A4%A9/u782.svg","https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E8%81%8A%E5%A4%A9/u791.svg"],
                calctime: '',
                text:' @ctitle(19)',
                'time|60-3600': 60,
                name: '@cname',
                'num|0-5':0
            }]
    })
    Mock.mock('/api/messageList', 'post', (config) => {
        // console.log(JSON.parse(config.body));
        const req = JSON.parse(config.body)
        const sortedMessageList = messageList.sort((a, b) => a.time - b.time);
        return {
            code: 200,
            message: '获取数据成功',
            data: {
                messageList:sortedMessageList,
            }
        }
    })
    
    const mineName = Mock.mock('@cname()')
    Mock.mock('/api/myname', 'post', (config) => {
        return{
            code: 200,
            message: '获取数据成功',
            data: mineName
        } 
    })
    Mock.mock('/api/registerList', 'post', (config) => {
        const token =Mock.mock({
            token : '@guid'
        })
        const img='https://img.axureshop.com/c2/e9/7b/c2e97b96ebac43fdaa2b01538e82639f/images/%E6%88%91%E7%9A%84/u842.svg'
        
        const req = JSON.parse(config.body)
        const registerList=[{
            name:req.name,
            password:req.password,
            tel:req.tel,
            male:req.male,
            passwordcard:req.passwordcard,
            location:req.location,
            work:req.work,
            token: token,
            img:img,
            talk:[]
        }]
        return{
            code: 200,
            message: '获取数据成功',
            data: registerList
        } 
    })
    
    Mock.mock('/api/scsData', 'post', (config) => {
        const scsData=Mock.mock({scsData:'@string("number", 5)'})
        return{
            code: 200,
            message: '获取数据成功',
            data: scsData
        } 
    })

    Mock.mock('/api/detailListData', 'post', (config) => {
        const req = JSON.parse(config.body)
        const { detailList } = Mock.mock({
            'detailList': 
                {
                    kind: ['近公交站','可以做饭','可以停车','提供早餐','全套海景','定时清洁','全天超市','设施齐全'],
                    text:' @ctitle(35)',
                    location:'@county(true)',
                    newKnd:[]
                }
            
            
        })
      
 
        // console.log(Math.ceil(Math.random()*detailList[0].kind.length));
      
        
        while( detailList.newKnd.length<4) {
             const kindindex= Math.ceil(Math.random()*detailList.kind.length)-1
             if(!detailList.newKnd.includes(detailList.kind[ kindindex])) {
                detailList.newKnd.push(detailList.kind[ kindindex])
             }
           
        }
        console.log( detailList.newKnd);

        return{
            code: 200,
            message: '获取数据成功',
            data:  detailList
        } 
    })

    Mock.mock('/api/nproData', 'post', (config) => {
        const { proData } = Mock.mock({
            'proData': 
                {
                    'bed|1-4':1,
                    'price|800-2000': 800,
                    'kind|1': ['珠海','吉隆坡','海南','成都','济州岛'],
                    "iLike|1-2": true,
                    'start|1-5': 1
                }
            
            
        })
        return{
            code: 200,
            message: '获取数据成功',
            data: proData
        } 
    })
    const {number}= Mock.mock({
        number: '@string("number", 12)'
            
    })
    Mock.mock('/api/number', 'post', (config) => {
      
        return{
            code: 200,
            message: '获取数据成功',
            data: number
        } 
    })